﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using System.Data;

namespace DAO
{
    public class PhieuNhapHang_DAO
    {
        private DataProvider _provider = new DataProvider();

        public PhieuNhapHang_DAO()
        {
            _provider.connect();
        }
        public DataTable GetDanhSachKH()
        {
            string s = "Select MaKH,TenKH"
                        + " from KhachHang "
                        + " order by  TenKH ASC";
            return _provider.executeQuery(s);
        }
        public int proc_Ins_PhieuNhap(PhieuNhapHang_DTO dto)
        {
            return _provider.proc_Ins_PhieuNhap(dto);
        }
        public void proc_Ins_CT_PhieuNhap(PhieuNhapHang_DTO dto)
        {
             _provider.proc_Ins_CT_PhieuNhap(dto);
        }
        public DataTable GetDanhSachNL()
        {
            string s = "Select MaNLG,TenNLG, DVT, BangGia.Gia "
                        + " from NLG, BangGia"
                        + " where NLG.MaNLG = BangGia.MaTP_NL and BangGia.PhanLoai = 1 "
                        + " order by TenNLG DESC";
            return _provider.executeQuery(s);
        }
        public void XoaPhieuNhapKhiNhapCTThatBai(int MaPN)
        {

            string s = "DELETE FROM PhieuNhapKho WHERE MaPhieuNhapKho = " + MaPN ;
            _provider.executeNonQuey(s);
        }
        public void Up_TienTra_PhieuNhapKho(int MaPN, int TienTra)
        {
            string s = "Update PhieuNhapKho set TienTra = "+ TienTra + " WHERE MaPhieuNhapKho = " + MaPN;
            _provider.executeNonQuey(s);
        }
    }
}

